// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//

#pragma once

#include <nebula/types/type_fwd.h>

namespace nebula::json {

    TURBO_EXPORT
    std::shared_ptr<Array> array_from_json(const std::shared_ptr<DataType> &,
                                           std::string_view json);

    TURBO_EXPORT
    std::shared_ptr<Array> dict_array_from_json(const std::shared_ptr<DataType> &type,
                                                std::string_view indices_json,
                                                std::string_view dictionary_json);

    TURBO_EXPORT
    std::shared_ptr<ChunkedArray> chunked_array_from_json(const std::shared_ptr<DataType> &,
                                                          const std::vector<std::string> &json);


    TURBO_EXPORT
    std::shared_ptr<RecordBatch> record_batch_from_json(const std::shared_ptr<Schema> &,
                                                        std::string_view);

    TURBO_EXPORT
    std::shared_ptr<Table> table_from_json(const std::shared_ptr<Schema> &schema,
                                           const std::vector<std::string> &json);

    TURBO_EXPORT
    std::shared_ptr<Scalar> scalar_from_json(const std::shared_ptr<DataType> &,
                                             std::string_view json);

    TURBO_EXPORT
    std::shared_ptr<Scalar> dict_scalar_from_json(const std::shared_ptr<DataType> &,
                                                  std::string_view index_json,
                                                  std::string_view dictionary_json);

    TURBO_EXPORT
    std::shared_ptr<Tensor> tensor_from_json(const std::shared_ptr<DataType> &type,
                                             std::string_view data, std::string_view shape,
                                             std::string_view strides = "[]",
                                             std::string_view dim_names = "[]");

    TURBO_EXPORT
    std::shared_ptr<Tensor> tensor_from_json(const std::shared_ptr<DataType> &type,
                                             std::string_view data,
                                             const std::vector<int64_t> &shape,
                                             const std::vector<int64_t> &strides = {},
                                             const std::vector<std::string> &dim_names = {});
}  // namespace nebula::json